package com.eastmelon.tcp;

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

/**
 * @author Administrator
 *客户端：
1.创建服务端点
2.读取客户端已有的文件数据
3.通过socket 输出流将数据发送给服务端
4.读取服务端反馈信息
5.关闭
 */
public class PicClient {
	public static void main(String[] args) throws Exception{
		Socket s=new Socket("127.0.0.1",10005);
		
		
		FileInputStream img=new FileInputStream("D:\\psb.jpg");
		OutputStream out =s.getOutputStream();
		byte[] buf=new byte[1024];
		int len=0;
		while((len=img.read(buf))!=-1){
			out.write(buf,0,len);
		}
        s.shutdownOutput();		
		
		InputStream in=s.getInputStream();
		byte[] bufIn=new byte[1024];
		int num=in.read(bufIn);
		System.out.println(new String(bufIn,0,num));
		
		
		img.close();
		s.close();
	}
}
